package org.example.controller;

import org.example.config.DeptTree;
import org.example.domain.Dept;
import org.example.result.Result;
import org.example.service.DeptService;
import org.example.vo.DeptVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("dept")
public class DeptController {
    @Autowired
    private DeptService deptService;

    @RequestMapping("list")
    public Result list(Dept dept){
        List<DeptVo> depts = deptService.listAll(dept);
        List<DeptVo> menuVos = DeptTree.toTree(depts);
        return Result.success(menuVos);
    }
}
